package io;

import java.io.BufferedWriter;
import java.io.FileOutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.nio.charset.StandardCharsets;
import java.util.Scanner;

public class PwDemo2 {
    public static void main(String[] args) throws Exception {
        FileOutputStream fos=new FileOutputStream("pw.txt");
        OutputStreamWriter osw=new OutputStreamWriter(fos, StandardCharsets.UTF_8);
        BufferedWriter bw=new BufferedWriter(osw);
        PrintWriter pw=new PrintWriter(bw,true);
        Scanner s=new Scanner(System.in);
        System.out.println("请开始输入，单独输入exit时结束");
        while(true){
            String str=s.nextLine();
            if("exit".equals(str)){
                break;
            }
            pw.println(str);
        }
        System.out.println("输入完毕");
        pw.close();
    }
}
